﻿

create proc [dbo].[GetPostleitzahlOrtList]
@WithNull	bit	= 0
as
begin
	set nocount on
	
	if @WithNull != 0
	begin
		select	p.EPLZ,
				p.LKZ,
				p.Ort,
				p.PLZ,
				p.Zone,
				p.Bundesland
		from	dbo.Postleitzahl p
		union all
		select	0		'EPLZ',
				null	'LKZ',
				null	'Ort',
				null	'Plz',
				0		'Zone',
				0		'Bundesland'
		order by p.LKZ,  p.PLZ, p.Ort
	end else
	begin
		select	p.EPLZ,
				p.LKZ,
				p.Ort,
				p.PLZ,
				p.Zone,
				p.Bundesland
		from	dbo.Postleitzahl p
		order by p.LKZ,  p.PLZ, p.Ort
	end
end
GO
GRANT EXECUTE
    ON OBJECT::[dbo].[GetPostleitzahlOrtList] TO PUBLIC
    AS [dbo];

